#!/bin/sh

# This shell script expands the Touch 1 executable and runs it

if [ -f pchp.gz ]
then
#   We have a gzipped file.  We need to decompress it
	if [ -f pchp ]
	then
#		We have a file called pchp.  It's probably this file.  Move it so we can unzip pchp w/o problems.
		rm pchp.sh
		mv pchp pchp.sh
	fi
	gzip -d pchp.gz
#   Make sure the new pchp file is executable.
	chmod +x pchp
	sync
fi

if [ -f /lib/libpthread.so.0 ]
then
	# do nothing.  It's OK
else
	if [ -f libp.gz ]
	then
#	   We have a gzipped file.  We need to decompress it
		gzip -d libp.gz
		mv libp /lib/libpthread.so.0
		chmod 755 /lib/libpthread.so.0
		sync
	fi
fi

if [ -f /lib/libz.so.1 ]
then
	# do nothing.  It's OK
else
	if [ -f libz.gz ]
	then
#	   We have a gzipped file.  We need to decompress it
		gzip -d libz.gz
		mv libz /lib/libz.so.1
		chmod 755 /lib/libz.so.1
		sync
	fi
fi

if [ -f /lib/m621-drv.so.1 ]
then
	# do nothing.  It's OK
else
	if [ -f m621-drv.gz ]
	then
#	   We have a gzipped file.  We need to decompress it
		gzip -d m621-drv.gz
		mv m621-drv /lib/m621-drv.so.1
		chmod 755 /lib/m621-drv.so.1
		sync
	fi
fi

# Now run the uncompressed pchp file with all of the desired command-line parameters
./pchp $*
